package com.zrwl.poscloud.xo.service.impl;
import com.zrwl.poscloud.base.entity.CallProductOrderHandle;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zrwl.poscloud.base.enums.EStatus;
import com.zrwl.poscloud.base.superI.SuperServiceImpl;
import com.zrwl.poscloud.commons.utils.ResultUtil;
import com.zrwl.poscloud.commons.utils.StringUtils;
import com.zrwl.poscloud.xo.global.MessageConf;
import com.zrwl.poscloud.xo.global.SQLConf;
import com.zrwl.poscloud.xo.global.SysConf;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import com.zrwl.poscloud.xo.mapper.CallProductOrderHandleMapper;
import com.zrwl.poscloud.xo.service.CallProductOrderHandleService;
import com.zrwl.poscloud.xo.vo.CallProductOrderHandleVO;

import javax.annotation.Resource;

/**
 * 通话订单处理记录 服务实现类
 *
 * @author 刘思童 AutoGenerate
 * @date 2023-06-14
 */
@Service
public class CallProductOrderHandleServiceImpl extends SuperServiceImpl<CallProductOrderHandleMapper,CallProductOrderHandle> implements CallProductOrderHandleService {

    @Autowired
    private CallProductOrderHandleService callProductOrderHandleService;
    @Resource
    private CallProductOrderHandleMapper callProductOrderHandleMapper;
    @Override
    public IPage<CallProductOrderHandleVO> getPageList(CallProductOrderHandleVO callProductOrderHandleVO){
       Page<CallProductOrderHandleVO> page = new Page<>();
       page.setCurrent(callProductOrderHandleVO.getCurrentPage());
       page.setSize(callProductOrderHandleVO.getPageSize());
       IPage<CallProductOrderHandleVO> pageList = callProductOrderHandleMapper.getPageList(page, callProductOrderHandleVO);
       List<CallProductOrderHandleVO> list = pageList.getRecords();
       pageList.setRecords(list);
       return pageList;
}
    @Override
    public List<CallProductOrderHandle> getAllList(CallProductOrderHandleVO callProductOrderHandleVO){
        QueryWrapper<CallProductOrderHandle> queryWrapper = new QueryWrapper<>();
        queryWrapper.ne(SQLConf.STATUS, EStatus.DISABLED);
        queryWrapper.orderByAsc(SQLConf.CREATE_TIME);
        List<CallProductOrderHandle> list = callProductOrderHandleService.list(queryWrapper);
        return list;
}
    @Override
    public String add(CallProductOrderHandleVO callProductOrderHandleVO){
        CallProductOrderHandle entity = new CallProductOrderHandle();
        BeanUtils.copyProperties(callProductOrderHandleVO, entity, SysConf.STATUS);
        entity.insert();
        callProductOrderHandleVO.setUid(entity.getUid());
        return ResultUtil.successWithMessage(MessageConf.INSERT_SUCCESS);}
    @Override
    public String edit(CallProductOrderHandleVO callProductOrderHandleVO){
        CallProductOrderHandle entity = callProductOrderHandleService.getById(callProductOrderHandleVO.getUid());
        BeanUtils.copyProperties(callProductOrderHandleVO, entity);
        entity.updateById();
        return ResultUtil.successWithMessage(MessageConf.UPDATE_SUCCESS);
}
    @Override
    public String delete(CallProductOrderHandleVO callProductOrderHandleVO){
        CallProductOrderHandle entity = callProductOrderHandleService.getById(callProductOrderHandleVO.getUid());
        entity.setStatus(EStatus.DISABLED);
        entity.updateById();
        return ResultUtil.successWithMessage(MessageConf.UPDATE_SUCCESS);
}
}
